*Replication .do file for "Why So Little Strategic Voting in India?" by Oliver Heath and Adam Ziegfeld
*Date: January 27, 2022
*All analyses completed in Stata 15

******************
*****Figure 1*****
******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
set scheme s1mono
graph pie, over(type_close) title(All voters) pie(1, color(gs13)) pie(2, color(black)) pie(3, color(white)) pie(4, color(gs8)) pie(5, color(gs3)) pie(6, color(gs6)) line(lcolor(black) lwidth(vthin)) legend(cols(1) region(lcolor(white))) plotregion(lcolor(white)) plabel(_all percent, size(medlarge) format(%3.1f))
graph save "1.gph", replace
graph pie if type_close!=6 & type_close!=5, over(type_close) title (Without constrained and unattached voters) pie(1, color(gs13)) pie(2, color(black)) pie(3, color(white)) pie(4, color(gs8)) line(lcolor(black) lwidth(vthin)) legend(cols(1) region(lcolor(white))) plotregion(lcolor(white)) plabel(_all percent, size(medlarge) format(%3.1f))
graph save "2.gph", replace
graph combine "1.gph" "2.gph"
clear

****************
****Figure 2****
****************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
set scheme s1mono

clogit first dfc pid dfc2012 contact bsp_dum sp_dum, group (finalserialno)
qui margins, at(pid=(0 1) dfc=0 dfc2012=0 contact=0 bsp_dum=1 sp_dum=0) 
marginsplot, ytitle(Prob. Winner) ylabel(0(.2)1, labsize(medium)) ytitle(, size(medium) margin(small)) xtitle(Close to a Party) xtitle(, size(medium) margin(small)) xlabel(, labsize(medium)) plotregion(lcolor(white)) level(95)
graph save "1.gph", replace
qui margins, at(dfc=(-30(5)30) pid=0 dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, ytitle(Prob. Winner) ylabel(0(.2)1, labsize(medium)) ytitle(, size(medium) margin(small)) xtitle(Distance from Contention 2017) xtitle(, size(medium) margin(small)) xlabel(, labsize(medium)) plotregion(lcolor(white)) level(95)
graph save "2.gph", replace

xtset finalserialno
xtreg belief dfc pid dfc2012 contact bsp_dum sp_dum, fe
qui margins, at(pid=(0 1) dfc=0 dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, ytitle(Likelihood of Victory) ylabel(0(1)4, labsize(medium)) ytitle(, size(medium) margin(small)) xtitle(Close to a Party) xtitle(, size(medium) margin(small)) xlabel(, labsize(medium)) plotregion(lcolor(white)) level(95)
graph save "3.gph", replace
qui margins, at(dfc=(-30(5)30) pid=0 dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, ytitle(Likelihood of Victory) ylabel(0(1)4, labsize(medium)) ytitle(, size(medium) margin(small)) xtitle(Distance from Contention 2017) xtitle(, size(medium) margin(small)) xlabel(, labsize(medium)) plotregion(lcolor(white)) level(95)
graph save "4.gph", replace

graph combine "1" "3" "2" "4"
clear

****************
****Figure 3****
****************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
set scheme s1mono
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum, group (finalserialno)
qui margins pid, at(dfc=(-40(10)40) dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, addplot(hist dfc, percent bin(30) yaxis(2) yscale(axis(2) alt))
clear


*****************************************************************************************
************************************APPENDIX A*******************************************
**Supplemental discussion of different strategies to identify voters’ party preferences**
*****************************************************************************************

*******************
*****Figure A1*****
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
set scheme s1mono
graph bar (mean) strategic_*, legend(colfirst region(lcolor(white))) plotregion(lcolor(white))
clear

*******************
*****Table A1******
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
*Each command below provides the data used to calculate the percentages in each row of Table A1
tab type_close
tab type_close14
tab type_close14_12
tab type_pref
tab type_pref14
tab type_pref14_12
tab type_prefclose

* "% of respondents with a preference" =  # of respondents falling into categories other than "Unattached" / total # of respondents
* "% strategic voters (of all respondents)" = # of respondents coded as "Strategic" / total # of respondents
* "% strategic voters (excluding unattached and constrained voters)" = # of respondents coded as "Strategic" / # of respondents falling into categories other than "Unattached" and "Constrained"
* "% strategic voters (of those preferring uncompetitive party)" = # of respondents coded as "Strategic" / (# of respondents coded as "Strategic" + # of respondents coded as "Expressive")
clear


*********************************************************************
*************************APPENDIX B**********************************
***************Muslims and strategic voting**************************
*********************************************************************

*******************
*****Table A2*****
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
tab type_close if x6==2
tab type_close if x6==1
tab type_close if x6==2 & type_close!=6 & type_close!=5
tab type_close if x6==1 & type_close!=6 & type_close!=5
clear

*******************
*****Table A3*****
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
tab type_close x6, row
clear

*******************
*****Table A4*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
clogit first dfc pid dfc2012 contact bsp_dum sp_dum if x6==1, group (finalserialno)
clogit first dfc pid dfc2012 contact bsp_dum sp_dum if x6==2, group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum if x6==1, group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum if x6==2, group (finalserialno)
clear

*********************************************************************
*************************APPENDIX C**********************************
****Additional figures and tables associated with Figures 2 and 3****
*********************************************************************

*******************
*****Table A5*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
clogit first dfc pid bsp_dum sp_dum, group (finalserialno)
clogit first dfc pid dfc2012 contact bsp_dum sp_dum, group (finalserialno)
xtset finalserialno
xtreg belief dfc pid bsp_dum sp_dum, fe
xtreg belief dfc pid dfc2012 contact bsp_dum sp_dum, fe
feologit belief dfc pid bsp_dum sp_dum 
feologit belief dfc pid dfc2012 contact bsp_dum sp_dum 
clear

*******************
*****Table A6*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
clogit first c.dfc##i.pid bsp_dum sp_dum, group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum, group (finalserialno)
xtset finalserialno
xtreg belief c.dfc##i.pid bsp_dum sp_dum, fe
xtreg belief c.dfc##i.pid dfc2012 contact bsp_dum sp_dum, fe
feologit belief c.dfc##i.pid bsp_dum sp_dum 
feologit belief c.dfc##i.pid dfc2012 contact bsp_dum sp_dum  
clear

*******************
*****Figure A2*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
set scheme s1mono
xtset finalserialno
xtreg belief c.dfc##i.pid dfc2012 contact bsp_dum sp_dum, fe
qui margins pid, at(dfc=(-40(10)40) dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, addplot(hist dfc, percent bin(30) yaxis(2) yscale(axis(2) alt))
graph save "1.gph", replace
feologit belief c.dfc##i.pid dfc2012 contact bsp_dum sp_dum
qui margins pid, at(dfc=(-40(10)40) dfc2012=0 contact=0 bsp_dum=1 sp_dum=0)
marginsplot, addplot(hist dfc, percent bin(30) yaxis(2) yscale(axis(2) alt))
graph save "2.gph", replace
graph combine "1" "2"
clear


*********************************************************************
*************************APPENDIX D**********************************
*********************Robustness Checks*******************************
*********************************************************************

*******************
*****Table A7*****
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
*Row: All respondents
tab type_close
*Row: Has beliefs aboutlikely winner and runner-up
tab type_close if q12!=8 & q13!=8
*Row: "Don't know" response for winner and runner-up
tab type_close if q12==8 | q13==8
clear

*******************
*****Table A8*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
clogit first dfc prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first c.dfc##c.prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first dfc i.prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first c.dfc##i.prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
clear

*******************
*****Figure A3*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
set scheme s1mono
clogit first c.dfc##c.prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
qui margins, at(dfc=(-40(10)40) prating=(0 2 4) dfc2012=0 contact=0 bsp_dum==1 sp_dum==0)
marginsplot
graph save "1.gph", replace
clogit first c.dfc##i.prating dfc2012 contact bsp_dum sp_dum, group (finalserialno)
qui margins, at(dfc=(-40(10)40) prating=(0 2 4) dfc2012=0 contact=0 bsp_dum==1 sp_dum==0)
marginsplot
graph save "2.gph", replace
graph combine "1.gph" "2.gph"
clear

*******************
*****Table A9*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
xtset finalserialno
xtreg belief dfc prating dfc2012 contact bsp_dum sp_dum, fe
xtreg belief c.dfc##c.prating dfc2012 contact bsp_dum sp_dum, fe
xtreg belief dfc i.prating dfc2012 contact bsp_dum sp_dum, fe
xtreg belief c.dfc##i.prating dfc2012 contact bsp_dum sp_dum, fe
clear

*******************
*****Figure A4*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
set scheme s1mono
xtset finalserialno
xtreg belief c.dfc##c.prating dfc2012 contact bsp_dum sp_dum, fe
qui margins, at(dfc=(-40(10)40) prating=(0 2 4) dfc2012=0 contact=0 bsp_dum==1 sp_dum==0)
marginsplot
graph save "1.gph", replace
xtreg belief c.dfc##i.prating dfc2012 contact bsp_dum sp_dum, fe
qui margins, at(dfc=(-40(10)40) prating=(0 2 4) dfc2012=0 contact=0 bsp_dum==1 sp_dum==0)
marginsplot
graph save "2.gph", replace
graph combine "1.gph" "2.gph"
clear

*******************
*****Table A10*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
*Create an alternative measure of distance from contention (2017)
replace dfc=0 if dfc<0
gen dfc_alt=dfc
replace dfc_alt=.005 if dfc_alt==0
gen lndfc=ln(dfc_alt)
*Create an alternative measure of distance from contention (2012) 
replace dfc2012=0 if dfc2012<0
gen dfc12_alt=dfc2012
replace dfc12_alt=0.005 if dfc12_alt==0
gen lndfc12=ln(dfc12_alt)

clogit first vote pid vote2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first c.vote##i.pid vote2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first lndfc pid lndfc12 contact bsp_dum sp_dum, group (finalserialno)
clogit first c.lndfc##i.pid lndfc12 contact bsp_dum sp_dum, group (finalserialno)
clear

*******************
*****Table A11*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
*Create an alternative measure of distance from contention (2017)
replace dfc=0 if dfc<0
gen dfc_alt=dfc
replace dfc_alt=.005 if dfc_alt==0
gen lndfc=ln(dfc_alt)
*Create an alternative measure of distance from contention (2012) 
replace dfc2012=0 if dfc2012<0
gen dfc12_alt=dfc2012
replace dfc12_alt=0.005 if dfc12_alt==0
gen lndfc12=ln(dfc12_alt)

xtset finalserialno
xtreg belief vote pid vote2012 contact bsp_dum sp_dum, fe
xtreg belief c.vote##i.pid vote2012 contact bsp_dum sp_dum, fe
xtreg belief lndfc pid lndfc12 contact bsp_dum sp_dum, fe
xtreg belief c.lndfc##i.pid lndfc12 contact bsp_dum sp_dum, fe
clear

*******************
*****Table A12*****
*******************
use "HeathZiegfeld APSR 2022 (Individual-level).dta"
logit correct1 close2winner contactwinner, cl(ac_id)
logit correct1 interest media knowledge i.education, cl(ac_id)
logit correct1 margin1_2 samewinner ENP, cl(ac_id)
logit correct1 close2winner contactwinner media interest i.education ENP, cl(ac_id)
logit correct1 i.winner_rate contactwinner media interest i.education ENP, cl(ac_id)
clear

*******************
*****Table A13*****
*******************
use "HeathZiegfeld APSR 2022 (Stacked).dta"
clogit first dfc dfc2012 pid contact bsp_dum sp_dum, group (finalserialno)
clogit first dfc dfc2012 pid contact bsp_dum sp_dum if q10!=8 & q14!=8 & q16!=8 , group (finalserialno)
clogit first dfc dfc2012 pid contact bsp_dum sp_dum if (q10==8 | q14==8 | q16==8), group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum, group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum if q10!=8 & q14!=8 & q16!=8, group (finalserialno)
clogit first c.dfc##i.pid dfc2012 contact bsp_dum sp_dum if (q10==8 | q14==8 | q16==8), group (finalserialno)
clear


*********************************************************************
*************************APPENDIX E**********************************
******Supplemental discussion of the case of Uttar Pradesh **********
*********************************************************************

*******************
*****Figure A5*****
*******************
use "UP election results (2007-17).dta"
set scheme s1mono
sort party year
twoway (connected seat year if party=="BJP", mcolor(orange) msymbol(circle) lcolor(orange) lpattern(solid)) (connected seat year if party=="SP", mcolor(red) msymbol(circle) lcolor(red) lpattern(solid)) (connected seat year if party=="BSP", mcolor(blue) msymbol(circle)  lcolor(blue) lpattern(solid)) (connected seat year if party=="INC", mcolor(green) msymbol(circle)  lcolor(green) lpattern(solid)), ylabel(0(20)100) xlabel(2007 2009 2012 2014 2017) legend(order(1 "BJP" 2 "SP" 3 "BSP" 4 "INC") region(lcolor(none))) plotregion(lcolor(none))
clear

*******************
*****Table A14*****
*******************
use "AC-level vote margins (2000-2019).dta"
keep if st_code=="S24"
bysort year: sum margin12 
bysort year: sum margin23 
clear

*******************
*****Figure A6*****
*******************
use "AC-level results (1961-2019).dta"
set scheme s1mono
histogram ENP_ac if C>=3 & st_code!="S24", percent
clear

*******************
*****Figure A7*****
*******************
use "AC-level seat volatility (1977-2019).dta"
set scheme s1mono
histogram changeper if year>=2008, width(10) start(0) frequency
clear

*******************
*****Figure A8*****
*******************
use "AC-level seat volatility (1977-2019).dta"
set scheme s1mono
histogram changeper if year<2008, width(10) start(0) frequency
clear

*******************
*****Figure A9*****
*******************
use "AC-level vote margins (2000-2019).dta"
set scheme s1mono 
histogram margin13, percent by(twoparty)
clear



